package com.mms.action.person;

import java.util.List;

import com.mms.dao.DepartmentManagementDao;
import com.mms.dao.PersonManagementDao;
import com.mms.entity.Department;
import com.mms.entity.Staff;
import com.opensymphony.xwork2.Action;

public class ModifyPersonAction implements Action{

	private int startpage;
	private String Sname;
	private String Spos;
	private String Spho;
	private String Spas;
	private int Ssex;
	private int Sman;
	private int Sdepment;
	private int modID;
	private boolean PmodisSuccess;
	private int account;
	private List<Department> depmes;
	private List<Staff> staffs;
	private int modState;
	private String modRecode;
	
	public int getStartpage() {
		return startpage;
	}

	public void setStartpage(int startpage) {
		this.startpage = startpage;
	}

	public String getSname() {
		return Sname;
	}

	public void setSname(String sname) {
		Sname = sname;
	}

	public String getSpos() {
		return Spos;
	}

	public void setSpos(String spos) {
		Spos = spos;
	}

	public String getSpho() {
		return Spho;
	}

	public void setSpho(String spho) {
		Spho = spho;
	}

	public String getSpas() {
		return Spas;
	}

	public void setSpas(String spas) {
		Spas = spas;
	}

	public int getSsex() {
		return Ssex;
	}

	public void setSsex(int ssex) {
		Ssex = ssex;
	}

	public int getSman() {
		return Sman;
	}

	public void setSman(int sman) {
		Sman = sman;
	}

	public int getSdepment() {
		return Sdepment;
	}

	public void setSdepment(int sdepment) {
		Sdepment = sdepment;
	}

	public int getModID() {
		return modID;
	}

	public void setModID(int modID) {
		this.modID = modID;
	}

	public int getAccount() {
		return account;
	}

	public void setAccount(int account) {
		this.account = account;
	}

	
	public List<Department> getDepmes() {
		return depmes;
	}

	public void setDepmes(List<Department> depmes) {
		this.depmes = depmes;
	}

	public List<Staff> getStaffs() {
		return staffs;
	}

	public void setStaffs(List<Staff> staffs) {
		this.staffs = staffs;
	}

	
	public boolean isPmodisSuccess() {
		return PmodisSuccess;
	}

	public void setPmodisSuccess(boolean pmodisSuccess) {
		PmodisSuccess = pmodisSuccess;
	}

	public int getModState() {
		return modState;
	}

	public void setModState(int modState) {
		this.modState = modState;
	}

	public String getModRecode() {
		return modRecode;
	}

	public void setModRecode(String modRecode) {
		this.modRecode = modRecode;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		PersonManagementDao pmd = new PersonManagementDao();
		Department department = new Department();
		department.setDeId(Sdepment);
		Staff staff = new Staff();
		staff.setSName(Sname);
		staff.setPosition(Spos);
		staff.setPhone(Spho);
		staff.setPassword(Spas);
		staff.setSex(Ssex);
		staff.setAdminFlag(Sman);
		staff.setDepartment(department);
		staff.setSId(modID);
		staff.setState(modState);
		staff.setReCode(modRecode);
		System.out.println("ssss--->"+modState);
		if(pmd.modifyPerson(staff)){
			PmodisSuccess = true;
		}else{
			PmodisSuccess = false;
		}
		DepartmentManagementDao dmd = new DepartmentManagementDao();
		staffs = pmd.getStaffs(startpage);
		depmes = dmd.getDepartments();
		account = pmd.getcount();
		System.out.println("---------------->"+modRecode);
		return "success";
	}

}
